package com.caregiver.watch.business.user.model.dto;

import com.caregiver.watch.business.user.enums.UserReminderintervalUnitEnum;
import com.caregiver.watch.business.user.enums.WeekDay;
import com.caregiver.watch.business.user.model.po.UserReminder;
import com.caregiver.watch.business.user.utils.UserInfoUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Set;

import static com.caregiver.watch.common.constant.NumberConstants.ONE;

/**
 * @Description: 添加用户提醒参数
 * @Author 疆戟
 * @Date 2025/8/23 18:19
 * @Version 1.0
 */
@Data
@Schema(title = "添加用户提醒参数")
public class AddUserReminderParam {

    /**
     * 提醒名称
     */
    @Schema(description = "提醒名称")
    private String reminderName;

    /**
     * 提醒内容
     */
    @Schema(description = "提醒内容")
    private String content;

    /**
     * 提醒开始时间
     */
    @Schema(description = "提醒开始时间(HH:mm)")
    @JsonFormat(pattern = "HH:mm")
    private LocalTime startTime;

    /**
     * 提醒结束时间
     */
    @Schema(description = "提醒结束时间(HH:mm)")
    @JsonFormat(pattern = "HH:mm")
    private LocalTime endTime;

    /**
     * 提醒间隔
     */
    @Schema(description = "提醒间隔")
    private Integer intervalValue;

    /**
     * 提醒间隔单位
     */
    @Schema(description = "提醒间隔单位")
    private UserReminderintervalUnitEnum intervalUnit;

    /**
     * 重复天(位掩码存储星期选择)
     */
    @Schema(description = "重复天(位掩码存储星期选择)")
    private Set<WeekDay> repeatDays;


    public UserReminder toPo() {
        UserReminder userReminder = new UserReminder();
        userReminder.setUserId(UserInfoUtils.getUserId());
        userReminder.setReminderName(this.getReminderName());
        userReminder.setContent(this.getContent());
        userReminder.setStartTime(this.getStartTime());
        userReminder.setEndTime(this.getEndTime());
        userReminder.setIntervalValue(this.getIntervalValue());
        userReminder.setIntervalUnit(this.getIntervalUnit().name());
        userReminder.setRepeatDaysSet(this.getRepeatDays());
        userReminder.setIsEnabled(ONE);
        return userReminder;
    }
}
